package com.ruoyi.omp.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteStaticsticsService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 客户信息降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteStaticsticsFactory implements FallbackFactory<RemoteStaticsticsService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteStaticsticsFactory.class);

    @Override
    public RemoteStaticsticsService create(Throwable throwable) {
        log.error("统计服务调用失败:{}", throwable.getMessage());
        return new RemoteStaticsticsService() {
            @Override
            public R genStaticByDate(String staticDate) {
                return R.fail("生成停车场日统计信息失败:" + throwable.getMessage());
            }
        };
    }
}
